<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use backend\utils\XHtml;

/* @var $this yii\web\View */
/* @var $model common\models\Article */

$this->title = $model->isNewRecord ? '新建视图' : '更新视图';
$this->params['breadcrumbs'][] = ['label' => '视图管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
    <div class="page-create">
        <div class="box box-primary">
            <div class="box-body">

                <?= $this->render('/site/error-summary', ['model' => $model]) ?>

                <?php $form = ActiveForm::begin([
                    'options' => ['class' => 'form-horizontal'],
                    'fieldConfig' => [
                        'template' => "{label}\n<div class=\"col-sm-6\">{input}</div>\n<div class=\"col-sm-4\">{hint}\n{error}</div>",
                        'labelOptions' => ['class ' => 'col-sm-2 control-label'],
                    ]
                ]); ?>
                <?= $form->field($model, 'type')->dropDownList(['栏目' => '栏目', '内容' => '内容']) ?>
                <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
                <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?>
                <?= $form->field($model, 'remark')->textarea(['maxlength' => true]) ?>

                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <?= XHtml::submitButton($model->isNewRecord ? '创建' : '更新') ?>&nbsp;&nbsp;
                    <?= XHtml::backButton() ?>&nbsp;&nbsp;
                    <?= XHtml::resetButton() ?>
                </div>
                <?php ActiveForm::end(); ?>
            </div>
        </div>
    </div>
<?php
$script = <<<JS
    $("#view-type").change(function() {
      if ($(this).val()=='目录'){
        $(".field-view-alias").find(".hint-block").html('确保模板管理<b style="color: red">目录页</b>下有该文件名');
      }else {
        $(".field-view-alias").find(".hint-block").html('确保模板管理<b style="color: red">内容页</b>下有该文件名');
      }
    });
JS;
$this->registerJs($script);
?>